package ai.example.langchain4j.config;

import ai.example.langchain4j.store.InMemoryChatMemoryStore;
import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class LangChain4jConfig {

  @Resource
  InMemoryChatMemoryStore inMemoryChatMemoryStore;

//    @Bean
//    ChatMemory chatMemory() {
//        //设置聊天记忆记录的message数量
//        return MessageWindowChatMemory.withMaxMessages(10);
//    }
//

  @Bean
  ChatMemoryProvider chatMemoryProvider() {
    return memoryId -> MessageWindowChatMemory.builder()
      .id(memoryId)
      .maxMessages(10)
      .chatMemoryStore(inMemoryChatMemoryStore)
      .build();
  }


}
